<!DOCTYPE html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
    <link rel="stylesheet" href="/static/style.css">
</head>
<body>
    <div class="wrapper">
        <div class="panel layui-panel">
            <form class="layui-form scms-form" lay-filter="form">
                <div class="layui-tab layui-tab-brief">
                    <ul class="layui-tab-title">
                        <li class="layui-this">基本设置</li>
                        <li>附件设置</li>
                    </ul>
                    <div class="layui-tab-content">
                        <div class="layui-tab-item layui-show">
                            <input type="text" name="id" value="{$site.id|default=0}" style="display: none;">
                            <div class="layui-form-item">
                                <label class="layui-form-label">网站开关：</label>
                                <div class="layui-input-block">
                                    <input type="radio" name="closed" value="0" title="开启"{:empty($site.closed)?' checked':''}>
                                    <input type="radio" name="closed" value="1" title="关闭"{:empty($site.closed)?'':' checked'}>
                                    <!-- <select name="closed">
                                        <option value="0"{:empty($site.closed)?' selected':''}>开启</option>
                                        <option value="1"{:empty($site.closed)?'':' selected'}>关闭</option>
                                    </select> -->
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">手机站开关：</label>
                                <div class="layui-input-block">
                                    <input type="radio" name="closed_mobile" value="0" title="开启"{:empty($site.closed_mobile)?' checked':''}>
                                    <input type="radio" name="closed_mobile" value="1" title="关闭"{:empty($site.closed_mobile)?'':' checked'}>
                                    <!-- <select name="closed_mobile">
                                        <option value="0"{:empty($site.closed_mobile)?' selected':''}>开启</option>
                                        <option value="1"{:empty($site.closed_mobile)?'':' selected'}>关闭</option>
                                    </select> -->
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">关闭原因：</label>
                                <div class="layui-input-block">
                                    <textarea name="closed_reason" placeholder="请输入关闭原因" class="layui-textarea">{$site.closed_reason|default=''}</textarea>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">网站名称：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="name" value="{$site.name|default=''}" placeholder="请输入网站名称" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">网站logo：</label>
                                <div class="layui-input-block">
                                    <div class="layui-input-group" style="width: 100%;">
                                        <div class="layui-input-prefix" style="padding: 0; width: 180px;">
                                            <div class="layui-btn-group">
                                                <button type="button" class="layui-btn layui-btn-primary" id="logo_upload"><i class="layui-icon layui-icon-upload-drag"></i> 上传</button>
                                                <button type="button" class="layui-btn layui-btn-primary" id="logo_preview"><i class="layui-icon layui-icon-eye"></i> 预览</button>
                                            </div>
                                        </div>
                                        <input type="text" name="logo" value="{$site.logo|default=''}" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">优化标题：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="title" value="{$site.title|default=''}" placeholder="请输入优化标题" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">关键字：</label>
                                <div class="layui-input-block">
                                    <textarea name="keywords" placeholder="请输入关键字" class="layui-textarea">{$site.keywords|default=''}</textarea>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">描述：</label>
                                <div class="layui-input-block">
                                    <textarea name="description" placeholder="请输入描述" class="layui-textarea">{$site.description|default=''}</textarea>
                                </div>
                            </div>
                        </div>
                        <div class="layui-tab-item">
                            <div class="layui-form-item">
                                <label class="layui-form-label">图像最大上传(M)：</label>
                                <div class="layui-input-block">
                                    <input type="number" name="image" value="{$site.image|default=''}" placeholder="请输入图像最大上传" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">图像文件类型：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="image_ext" value="{$site.image_ext|default=''}" placeholder="请输入图像文件类型" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">视频最大上传(M)：</label>
                                <div class="layui-input-block">
                                    <input type="number" name="video" value="{$site.video|default=''}" placeholder="请输入视频最大上传" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">视频文件类型：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="video_ext" value="{$site.video_ext|default=''}" placeholder="请输入视频文件类型" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">附件最大上传(M)：</label>
                                <div class="layui-input-block">
                                    <input type="number" name="attachment" value="{$site.attachment|default=''}" placeholder="请输入附件最大上传" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">附件文件类型：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="attachment_ext" value="{$site.attachment_ext|default=''}" placeholder="请输入附件文件类型" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button type="button" class="layui-btn" lay-filter="save" lay-submit>保存设置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</body>
</html>
<script src="/static/layui/layui.js"></script>
<script>
layui.use(function() {
    var $ = layui.jquery,
        form = layui.form,
        upload = layui.upload;
    
    form.on('submit(save)', function(obj) {
        var postData = obj.field;
        var loadIndex = layer.load();
        $.post("{:url('admin/site/sitesave')}", postData, function(res) {
            layer.close(loadIndex);
            if (res.code > 0) {
                layer.alert(res.msg, {icon: 2});
            } else {
                layer.msg(res.msg, {time: 500});
            }
        });
        return false;
    });

    upload.render({
        elem: '#logo_upload',
        url: "{:url('admin/index/upload')}",
        accept: 'images',
        acceptMime: 'image/*',
        done: function(res) {
            if (res.code > 0) {
                layer.alert(res.msg, {icon: 2});
            } else {
                layer.msg(res.msg, {time: 500});
                $('input[name="logo"]').val(res.data.src);
            }
        }
    });

    $('#logo_preview').click(function() {
        layer.photos({ photos: { 'data': [{ 'src': $('input[name="logo"]').val() }]} });
    });
});
</script>